package com.example.a26436.newpractise.practise1;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.a26436.newpractise.R;

/**
 * Created by 26436 on 2020/9/25.
 */


public class MyFragment extends Fragment {
    public static final String TITLE = "title";

    public static MyFragment newInstance(String title){
        MyFragment fragment=new MyFragment();
        Bundle bundle= new Bundle();
        bundle.putString(TITLE,title);
        fragment.setArguments(bundle);
        return fragment;
    }
    @Nullable
    @Override
    public View onCreateView(
            @NonNull LayoutInflater inflater,
            @Nullable ViewGroup container,
            @Nullable Bundle savedInstanceState) {
        View inflate = inflater.inflate(R.layout.mine_fragment, null, false);
        Bundle arguments = getArguments();
        String title = null;
        if(arguments != null){
            title = arguments.getString(TITLE);
        }
        TextView TvTitle = inflate.findViewById(R.id.tv_title_mine_fragment);
        TvTitle.setText(TextUtils.isEmpty(title)?
        "默认的mineFragment":title);

        return inflate;
    }
}
